package com.hcrazy.manchester.app.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;

import com.hcrazy.manchester.app.pojo.Admin;

@Controller
@SessionAttributes("admin")
@RequestMapping("/admin")
public class loginController {

	@RequestMapping(value="/login",method=RequestMethod.GET)
	public void adminLogin(Model model,@RequestParam(required=false) String url){
		model.addAttribute("url",url);
	}
	
	@RequestMapping(value="/logout",method=RequestMethod.GET)
	public String logout(@ModelAttribute("admin") Admin admin,SessionStatus status){
		status.setComplete();
		
		return "redirect:/admin/login";
	}
}
